package eu.robico.simulator.simulatorinterface.actionpanel;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

class ActionPanelMouseListener extends MouseAdapter
{
	private ActionPanel actionPanel;
	
	public ActionPanelMouseListener(ActionPanel actionPanel)
	{
		this.actionPanel = actionPanel;
	}
	
	public void mousePressed(MouseEvent e)
	{
		if (e.getSource().getClass().equals(ActionPanel.class) && e.isPopupTrigger())
            mainActionPanelPopUp(e);
    }

    public void mouseReleased(MouseEvent e)
    {
        if (e.isPopupTrigger())
            mainActionPanelPopUp(e);
    }

    private void mainActionPanelPopUp(MouseEvent e)
    {
        ActionPanelPopUp menu = new ActionPanelPopUp(actionPanel, e.getPoint());
        menu.show(e.getComponent(), e.getX(), e.getY());
    }
}
